[Using $this when not in object context in] php error

Posted by JasonS on Stack Overflow See other posts from Stack Overflow or by JasonS
Published on 2010-03-24T16:18:59Z Indexed on 2010/03/24 16:33 UTC
Read the original article Hit count: 202

Filed under:
|
|

I have solved this problem, I just need to know what to do. I get the above error because I just realised that the class is being run as class::function($values) instead of class->function($values).

Does anyone know how to convert this function to instantiate the class then run the function with values?

private function _load($values=null) {

    define('LOADED_CONTROLLER', $this->controller);
    define('LOADED_FUNCTION', $this->function);

    $function = $this->function;

    $controller = new $this->controller;
    ($values == null) ? $controller->$function() : call_user_func_array(array($this->controller, $function), $values);
}

© Stack Overflow or respective owner

Related posts about php

Related posts about class